package com.sskj.lib.model.repository;


import android.arch.lifecycle.LiveData;

import com.sskj.lib.bean.WalletBean;
import com.sskj.lib.model.room.WalletBeanDao;

import java.util.List;

import javax.inject.Inject;
import javax.inject.Named;

import io.reactivex.schedulers.Schedulers;

/**
 * Created by lv on 18-5-7.
 */
//@Singleton
public class WalletBeanRepository {


    public WalletBeanDao walletBeanDao;

    @Inject
    public WalletBeanRepository(@Named("WalletBeanDao") WalletBeanDao walletBeanDao) {
        this.walletBeanDao = walletBeanDao;
    }

    public LiveData<List<WalletBean>> getAllUser() {
        return walletBeanDao.getAll();
    }



    public void insert(WalletBean user) {
        Schedulers.newThread().scheduleDirect(() -> walletBeanDao.insert(user));
    }
    public void delete(WalletBean user) {
        Schedulers.newThread().scheduleDirect(() -> walletBeanDao.delete(user));
    }

    public void clear() {
        Schedulers.newThread().scheduleDirect(() -> walletBeanDao.deleteAll());
    }

    public void update(WalletBean user) {
        Schedulers.newThread().scheduleDirect(() -> walletBeanDao.update(user));
    }
}
